import matplotlib.pyplot as plt
import numpy as np

real_names=['千里千寻','玩具总动员4','黑衣人']

#三天内票房书
real_num1=[7548,4013,1673]
real_num2=[5453,1840,1080]
real_num3=[4348,2345,1890]

width=0.3
x=np.arange(len(real_names))
plt.bar(x,real_num1,alpha=0.5,width=width,label=real_names[0])
plt.bar([i+width for i in x],real_num2,alpha=0.5,width=width,label=real_names[1])
plt.bar([i+2*width for i in x],real_num3,alpha=0.5,width=width,label=real_names[2])
#设置x坐标
x_label=['第{}天'.format(i+1) for i in x]
plt.rcParams['font.sans-serif']=['SimHei']
plt.xticks([i+width for i in x],x_label)
#添加图例
plt.ylabel('票房数')
#添加
plt.legend()
plt.show()